package com.neusoft.elmboot.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.neusoft.elmboot.po.Food;

@Mapper
public interface FoodMapper {

	@Select("select * from food where businessId=#{businessId} order by foodId")
	public List<Food> listFoodByBusinessId(Integer businessId);

	@Select(("select * from food where foodId=#{foodId}"))
	public Food getFoodById(Integer foodId);
	
	@Insert("insert into food(foodName,foodExplain,foodImg,foodPrice,businessId,remarks,foodQuantity) values(#{foodName},#{foodExplain},#{foodImg},#{foodPrice},#{businessId},#{remarks},#{foodQuantity})")
	@Options(useGeneratedKeys = true,keyProperty="foodId",keyColumn="foodId")
	public int createFood(Food food);
	
	public int removeFood(Food food);
	
	@Update("update food set foodName=#{foodName},foodExplain=#{foodExplain},foodImg=#{foodImg},foodPrice=#{foodPrice},remarks=#{remarks},foodQuantity=#{foodQuantity} where foodId=#{foodId}")
	public int updateFood(Food food);
	
	public int buyFood(Food food);
}
